<?php

/**
 * NOTICE OF LICENSE
 *
 * THIS SOURCE FILE IS PART OF EVEBIT'S PRIVATE PROJECT.
 * 
 * DO NOT USE THIS FILE IN OTHER PLACE.
 *
 * @package   App_Sample
 * @author    Cheng Wei <berlios.o@gmail.com>
 * @version   $$Id: GetSortClass.php 130 2011-03-18 03:10:02Z cheng.wei $$
 * @copyright Copyright (c) 2008 Evebit Inc. China (http://www.evebit.com)
 */

/**
 * Get Revage rate and get rate count
 * 
 * @package   App_Sample
 * @author    Chang ZhenHua <chang.zhenhua@gmail.com>
 * @version   $$Id: GetSortClass.php 130 2011-03-18 03:10:02Z cheng.wei $$
 */
class Evebit_View_Helper_GetGoogleMaps extends Zend_View_Helper_Abstract {
	protected $firstload = false;	
	
    function getGoogleMaps($latitude=null,$longitude=null,$name=null,$map_zoom_level=null) {
    	//load script
    	if (!$this->firstload) {
	    	if (Zend_Auth::getInstance()->hasIdentity()) {
				$user = Zend_Auth::getInstance()->getIdentity();
				$lan = substr($user->getData('language'),0,2);
			} else {
				$lan = 'en';
			}
    		return "<script charset=\"UTF-8\" src=\"http://ditu.google.com/maps/api/js?sensor=false&language=".$lan."\" type=\"text/javascript\"></script>
    		<script type=\"text/javascript\">
				var x = '".$latitude."';  
				var y = '".$longitude."';
				var name = '".$name."';
				var minLat = 4;
				var maxLat = 70;
				var minLng = 73;
				var maxLng = 135;
				var centerLat = (minLat+maxLat)/2;
				var centerLng = (minLng+maxLng)/2;
				var city = new google.maps.LatLng(x, y);
				var minZoomLevel = '".$map_zoom_level."';
				var minZoomLevel = parseInt(minZoomLevel); 
				var map = new google.maps.Map(document.getElementById('map_canvas'), {  
				    zoom: minZoomLevel,  
				    center: new google.maps.LatLng(centerLat, centerLng),
				    mapTypeId: google.maps.MapTypeId.ROADMAP  
				});   
				
				google.maps.event.addListener(map, 'zoom_changed',  
				function() {  
				    if (map.getZoom() < minZoomLevel) map.setZoom(minZoomLevel);  
				});   
				  
				var strictBounds = new google.maps.LatLngBounds(  
				    new google.maps.LatLng(minLat, minLng),   
				    new google.maps.LatLng(maxLat, maxLng  
				));  
				var marker = new google.maps.Marker({map: map, position: city,title:name});
				var markerS = new google.maps.MarkerShape();
				
				
			</script>";
    	}
	}
	
}